package ua.yandex.skipass;

/**
 * Пропуск
 *
 * @author WslF
 */
public abstract class Pass {

    private static int numberOfPasses = 0;
    private int id;
    protected TypeOfPasses type;

    protected Pass(TypeOfPasses type) {
        this.id = ++numberOfPasses;
        this.type = type;
    }

    protected abstract boolean couldUse();

    protected abstract void use();

    protected static int getNumberOfPasses() {
        return numberOfPasses;
    }

    static Pass createNewPass(TypeOfPasses typeOfPasses) {
        switch (typeOfPasses) {
            case OneDay:
            case TwoDays:
            case FiveDays:
            case Morning:
            case Afternoon:
            case HolidayOneDay:
            case HolidayTwoDays:
            case HolidayMorning:
            case HolidayAfternoon:
                return new PassDays(typeOfPasses);

            case Spring:
            case Fall:
            case Winter:
                return new PassSeason(typeOfPasses);

            default:
                return new PassTimes(typeOfPasses);
        }

    }
}
